//
//  MyBillDetailVC.m
//  SelfDrivingTravelling-IOS
//
//  Created by Teplot_01 on 16/8/30.
//  Copyright © 2016年 Teplot_01. All rights reserved.
//

#import "MyBillDetailVC.h"

@interface MyBillDetailVC ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation MyBillDetailVC
{
    UITableView *_tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = superBackgroundColor;
    self.title = self.time;
    [self initTableView];
    [self initView];
    //设置多余的分割线不显示
    _tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
}
- (void)initTableView{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(10, 30, KScreenWidth - 20, KScreenHeight - 10)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.clipsToBounds = NO;
    _tableView.layer.shadowColor = [UIColor grayColor].CGColor;
    _tableView.layer.shadowOffset = CGSizeMake(2,2);//shadowOffset阴影偏移,x向右偏移2，y向下偏移2，默认(0, -3),这个跟shadowRadius配合使用
    _tableView.layer.shadowOpacity = 0.5;
    _tableView.layer.shadowRadius = 2;
    [self.view addSubview:_tableView];
}
- (void)initView{
    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(10, 64, KScreenWidth - 20, 30)];
    topView.backgroundColor = superBackgroundColor;
    UILabel *titleLb = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 130, 30)];
    NSString *total = [NSString stringWithFormat:@"%@%@%@",@"今日共消费：", self.dayMoney,@"元"];
    titleLb.text = total;
    titleLb.textColor = grayTextColor;
    titleLb.font = [UIFont systemFontOfSize:13];
    [topView addSubview:titleLb];
    UILabel *nameLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth - 110, 0, 80, 30)];
    nameLb.text = self.activityName;
    nameLb.textAlignment = NSTextAlignmentRight;
    nameLb.textColor = grayTextColor;
    nameLb.font = [UIFont systemFontOfSize:13];
    [topView addSubview:nameLb];
    [self.view addSubview:topView];
}
#pragma - mark UITableView delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.dayDetailArr.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSArray *arr = self.dayDetailArr[section][@"billList"];
    return arr.count+1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 25;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [[UITableViewCell alloc]init];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row == 0) {
        UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(15, 5, 15, 15)];
        imageV.image = [UIImage imageNamed:@"icon"];
        [cell.contentView addSubview:imageV];
        UILabel *nameLb = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 100, 25)];
        nameLb.text = self.dayDetailArr[indexPath.section][@"payContent"];
        nameLb.font = [UIFont systemFontOfSize:15];
        [cell.contentView addSubview:nameLb];
        UILabel *SpendLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth-150, 0, 100, 25)];
        NSString *dayTotal = [NSString stringWithFormat:@"%@%@%@", @"-", self.dayDetailArr[indexPath.section][@"money"],@"元"];
        SpendLb.text = dayTotal;
        SpendLb.textColor = grayTextColor;
        SpendLb.font = [UIFont systemFontOfSize:15];
        SpendLb.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:SpendLb];
    }
    if (indexPath.row > 0) {
        UILabel *nameLb = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 100, 25)];
        nameLb.text = self.dayDetailArr[indexPath.section][@"billList"][indexPath.row-1][@"payerName"];
        nameLb.font = [UIFont systemFontOfSize:13];
        nameLb.textColor = LightGray_Color;
        [cell.contentView addSubview:nameLb];
        UILabel *SpendLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth-150, 0, 100, 25)];
        NSString *dayTotal = [NSString stringWithFormat:@"%@%@%@", @"-", self.dayDetailArr[indexPath.section][@"billList"][indexPath.row-1][@"money"],@"元"];
        SpendLb.text = dayTotal;
        SpendLb.textColor = LightGray_Color;
        SpendLb.font = [UIFont systemFontOfSize:13];
        SpendLb.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:SpendLb];
    }
    return cell;
}
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
//    return 35;
//}
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
//    UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, KScreenWidth, 35)];
//    customView.backgroundColor = White_Color;
//    UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(8, 10, 15, 15)];
//    imageV.image = [UIImage imageNamed:@"icon"];
//    [customView addSubview:imageV];
//    UILabel *timeLb = [[UILabel alloc]initWithFrame:CGRectMake(30, 0, 100, 35)];
//    timeLb.text = @"酒店住宿";
////    timeLb.textColor = White_Color;
//    timeLb.font = [UIFont systemFontOfSize:16];
//    [customView addSubview:timeLb];
//    UILabel *titleLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth - 100, 0, 50, 35)];
//    titleLb.text = @"－126";
////    titleLb.textColor = White_Color;
//    titleLb.textAlignment = NSTextAlignmentRight;
//    titleLb.font = [UIFont systemFontOfSize:16];
//    [customView addSubview:titleLb];
//    return customView;
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
